# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Contributor: Stefan Wagner <stw@bit-strickerei.de>
# Maintainer: omni <omni+alpine@hack.org>
pkgname=macchanger
pkgver=1.7.0
pkgrel=3
pkgdesc="An utility for viewing/manipulating the MAC address of network interfaces"
url="https://github.com/alobbs/macchanger"
arch="all"
license="GPL-3.0-or-later"
makedepends="linux-headers"
subpackages="$pkgname-doc"
source="https://github.com/alobbs/macchanger/releases/download/$pkgver/macchanger-$pkgver.tar.gz
	https://ftp.debian.org/debian/pool/main/m/macchanger/macchanger_1.7.0-5.4.debian.tar.xz
	fix-caddr_t.patch
	"

prepare() {
	default_prepare

	patch -p1 < "$srcdir"/debian/patches/02-fix_usage_message.patch
	patch -p1 < "$srcdir"/debian/patches/06-update_OUI_list.patch
	patch -p1 < "$srcdir"/debian/patches/08-fix_random_MAC_choice.patch
	patch -p1 < "$srcdir"/debian/patches/check-random-device-read-errors.patch
	patch -p1 < "$srcdir"/debian/patches/verify-changed-MAC.patch
}

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var
	make
}

check() {
	./src/macchanger --help > /dev/null
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm644 "$srcdir"/debian/changelog \
		"$pkgdir"/usr/share/doc/"$pkgname"/debian.changelog
}

sha512sums="
69f2008ace6ff8223ecf25805c08ddf42add9ed16c65f3bb57f74b8b0d080d584381ce79592d2ef581a9ba73f12624dae8db63dbb12e4875dfd29d828a4a5da3  macchanger-1.7.0.tar.gz
b50b52532fc987f443088f2a4d0f2327dac972e69bc4c0bc0a94de4583df76c7d32c40a143d24b7fa6e066fc36b89c4b160c02b26860c484aab5054a4032f0cc  macchanger_1.7.0-5.4.debian.tar.xz
00d59ce7562f0f011bd00f68d6e9aa4dd09d1dfb1aff4cb7291602e02d7015fb1f5038037c638e79f8aaf3c4787ef549c83d60303512b7d983b7f2ab386ccd21  fix-caddr_t.patch
"
